package top.malaoshi.netdisk.filter;

import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebFilter("/*" )
@Deprecated
public class StaticMappingFilter implements Filter {
    public void init(FilterConfig config) throws ServletException {
    }

    public void destroy() {
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest req=(HttpServletRequest)request;
        HttpServletResponse resp=(HttpServletResponse)response;
        request.setCharacterEncoding("utf-8");
        String servletPath = req.getServletPath();
        String path = this.getClass().getResource("/").getPath();
//        String staticPath = path+servletPath;
//        String staticPath = "/WEB-INF/classes/static"+servletPath;
//        String staticPath = "/WEB-INF/classes/resources"+servletPath;
//        String staticPath = "/WEB-INF/static"+servletPath;
        String staticPath = "/WEB-INF/classes/statica"+servletPath;
        request.getRequestDispatcher(staticPath).forward(request,response);
//        chain.doFilter(request, response);
//        resp.sendRedirect("1.html");
    }
}
